<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 函数返回值的提取
        // 1
        // let fn = function() {
        //     return ['hello','world']
        // }

        // let [a,b,c] = fn()
        // console.log(a,b,c)//'hello','world',undefined


        // 2
        // let fn1 = function() {
        //     return {
        //         a: 1, b:2, c:3
        //     }
        // }

        // let {a,c,b, d} = fn1()
        // console.log(a, b, c, d)//1,2,3,undefined


        // 3
        let fn2 = function() {
            return {
                a: 'a',
                b: 'b',
                fn: function() {
                    console.log(this.a)
                }
            }
        }

        let a = 99, b = 88
        let {a:num1, b:num2, fn} = fn2()
        // {num1='a',num2='b',function() {console.log(this.a)}}

        // console.log(a, b, num1, num2) //99,88,"a,","b"

        // let fn = function() {console.log(this.a)};
        // fn() //undefined,因为fn是在window下执行的,但是let a = 99又是一个单独的块，不算是window，所以是undefined
        fn2().fn() //a,因为是在fn2中执行的
    </script>
</body>
</html>